package com.tmall.service.impl;

import com.tmall.pojo.User;
import com.tmall.service.LikeTheArticle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.Objects;

/**
 * @author 吕兵星
 * @date 2020/12/3 11:33
 */
@Service
public class LikeTheArticleImpl implements LikeTheArticle {
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;
    @Override
    public int likeIncrement(User user) {
            Long like = redisTemplate.opsForSet().add("like", user);
        return Objects.requireNonNull(redisTemplate.opsForSet().size("like")).intValue();
    }
}
